import javax.swing.*;

public class EmployeeTest {
    public static void main(String[] args) {
        Employee[] employee = {
                new Employee("张三", "经理", 9000),
                new Employee("李四", "员工", 6000),
                new Employee("王五", "会计", 5000),
                new Employee("小红", "助理", 8000),
                new Employee("小兰", "出纳", 6000),
                new Employee("小王", "采购", 5500)
        };


        /*
        删除
         */
        String name = JOptionPane.showInputDialog(null,"输入要删除的员工名字");
        int index = -1;
        for (int i =0;i<employee.length;i++){
            if (name.equals(employee[i].name)){
                index = i;
                break;
            }
        }
        if (index == -1){
            JOptionPane.showMessageDialog(null,"查无此人");
        }
        if (index != -1) {
            for (int i = index; i < employee.length - 1; i++) {
                employee[i] = employee[i + 1];
            }
            for (int i = 0; i < employee.length - 1; i++) {
                System.out.println(employee[i].name + "  " + employee[i].job + "  " + employee[i].salary);
            }
        }







        /*
         排序
         */
//        for (int i=0;i<employee.length-1;i++){
//            for (int j=0;j<employee.length-1-i;j++){
//                if (employee[j].salary>employee[j+1].salary){
//                    Employee temp = employee[j];
//                    employee[j] = employee[j+1];
//                    employee[j+1] = temp;
//                }
//            }
//        }
//
//        for (Employee e:employee){
//            System.out.println(e.name+"  "+e.job+"  "+e.salary);
//        }


        /*
        修改信息
         */
//        String name = JOptionPane.showInputDialog(null,"输入要修改信息的员工名字");
//        Employee em = null;
//        for (Employee e:employee){
//            if (e.name.equals(name)){
//                em = e;
//                break;
//            }
//        }
//        if (em == null){
//            JOptionPane.showMessageDialog(null,"查无此人");
//        }else {
//            em.salary += 500;
//        }
//
//        for (Employee e:employee){
//            System.out.println(e.name+"  "+e.salary);
//        }





    }
}
